package com.pkx.cloud.fse7.dms.realtimestate.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.cloud.fse7.dms.realtimestate.entity.RealTimeState;
import com.pkx.cloud.fse7.dms.realtimestate.service.RealTimeStateService;
import com.pkx.cloud.whzx.comn.ORpose;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 控制器
 *
 * @author ly
 * @since 2020-10-14
 */
@RestController
@RequestMapping("/dms/real-time-state")
@Api(value = "门禁状态", tags = "门禁状态")
@Slf4j
@ORpose
public class RealTimeStateController {

    @Autowired
    private RealTimeStateService realTimeStateService;

    @ApiOperation("分页列表")
    @GetMapping("/page")
    public Page<RealTimeState> page(Page page, RealTimeState realTimeState) {
        return realTimeStateService.pageList(page, realTimeState);
    }

    @ApiOperation("列表")
    @GetMapping("/list")
    public List<RealTimeState> list(RealTimeState realTimeState) {
        return realTimeStateService.listByEntity(realTimeState);
    }

    @ApiOperation("详情")
    @GetMapping(value = "/{id}")
    public RealTimeState selectById(@PathVariable("id") Long id) {
        return realTimeStateService.selectById(id);
    }

    @GetMapping("/queryPage")
    @ApiOperation("门禁分页列表")
    public Page<List<Map<String, Object>>> queryPage(Page page, @RequestParam(required = false, defaultValue = "-1") String areaId) {
        return realTimeStateService.queryPage(page, areaId);
    }

    @GetMapping("/queryList")
    @ApiOperation("门禁列表")
    public List<Map<String, Object>> queryList(@RequestParam(required = false, defaultValue = "-1") String areaId) {
        return realTimeStateService.queryList(areaId);
    }

    @GetMapping("/readList")
    @ApiOperation("读头列表")
    public List<Map<String, Object>> readList(@RequestParam(required = false, defaultValue = "-1") String areaId) {
        return realTimeStateService.readList(areaId);
    }

    @GetMapping("/statistical")
    @ApiOperation("门禁在线离线数量")
    public Map statistical(@RequestParam(required = false, defaultValue = "-1") String areaId) {
        return realTimeStateService.statistical(areaId);
    }

    @GetMapping("/offline")
    @ApiOperation("离线门禁明细")
    public Page<List<Map<String, Object>>> offline(Page page, @RequestParam(required = false, defaultValue = "-1") String areaId) {
        return realTimeStateService.offline(page, areaId);
    }

    @ApiOperation("授权分页列表")
    @GetMapping("/grantPage")
    public Page<List<Map<String, Object>>> grantPage(Page page, Integer devNo, Integer doorNo) {
        return realTimeStateService.grantPage(page, devNo, doorNo);
    }

    @ApiOperation("授权列表")
    @GetMapping("/grantList")
    public List<Map<String, Object>> grantList(Integer devNo, Integer doorNo) {
        return realTimeStateService.grantList(devNo, doorNo);
    }
}
